package edu.hnzj.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import edu.hnzj.entity.Commodity;
import edu.hnzj.service.CommodityService;
import edu.hnzj.util.JsonResult;

@Controller
@RequestMapping("/commodtiy")
public class CommodtityController {
	@Resource
	private CommodityService service;
	
	
	@RequestMapping("/commodtiyList.do")
	@ResponseBody
	public JsonResult<List<Commodity>> emoListExecute(){
		JsonResult<List<Commodity>> result = service.commodityList();
		return result;
	};
	
	@RequestMapping("/commodtiyadd.do")
	@ResponseBody
	public JsonResult<Object> addExecute(Commodity commodity){
		JsonResult<Object> result = service.add(commodity);
		return result;
		
	}

	@RequestMapping("/commodtiydelete.do")
	@ResponseBody
	public JsonResult<Object> deleteExecute(int id){
		JsonResult<Object> result = service.delete(id);
		return result;	
	}

	@RequestMapping("/commodtiyupdate.do")
	@ResponseBody
	public JsonResult<Object> updateExecute(Commodity commodity){
		JsonResult<Object> result = service.update(commodity);
		
		return result;	
	}
	
	@RequestMapping("/findById.do")
	@ResponseBody
	public JsonResult<List<Commodity>> findByIdExecute(int id){
		JsonResult<List<Commodity>> result = service.findById(id);
		return result;
	};
	
	

}
